# 家具类
class Furniture:
    def __init__(self, name, area):
        self.name = name
        self.area = area

    def __str__(self):
        return "[%s] 占地 %.2f " % (self.name, self.area)


# 房子
class Hourse:
    def __init__(self, hourse_type, area):
        self.hourse_type = hourse_type
        self.area = area
        self.free_area = area  # 剩余面积
        self.item_list = []  # 家具列表

    def __str__(self):
        return ("户型：%s \n"
                "总面积：%.2f [剩余：%.2f] \n"
                "家具：%s"
                % (self.hourse_type,
                   self.area, self.free_area,
                   self.item_list))

    def add_item(self, item):
        if self.free_area > item.area:
            self.item_list.append(item.name)
            self.free_area -= item.area
            print("要添加 %s, 剩余：%.2f" % (item, self.free_area))
        else:
            print("请选择小一些的家具，房子剩余空间不足[剩余 %.2f]" % self.free_area)
            return


# 1. 盖房子
my_hourse = Hourse("三室两厅", 60)
print(my_hourse)

print("*" * 31)

# 2. 创建家具
bed = Furniture("席梦思", 4)  # 床
wardrobe = Furniture("衣柜", 2)  # 衣柜
board = Furniture("餐桌", 1.5)  # 餐桌

my_hourse.add_item(bed)
my_hourse.add_item(wardrobe)
my_hourse.add_item(board)

print("*" * 31)

# 3. 装修完毕
print(my_hourse)
